package top.minuy.algorithm.sort.heap;

import top.minuy.util.constant.SortType;
import top.minuy.util.generate.ArrayGenerator;
import top.minuy.util.helper.SortingHelper;
import java.util.Arrays;
/**
 * @author Minuy
 * @time 11:29
 * @date 2021/9/18
 */
public class Test {
    public static void main(String[] args) {
        System.out.println("排序测试：");
        Integer[] d = {8, 1, 3, 1, 2, 4, 9,0};
        HeapSort.sort(d);
        for (Integer i : d) {
            System.out.print(i + " ");
        }
        System.out.println();

        System.out.println("性能测试：");

        int[] dataSize = {10, 100, 1000, 10000, 100000};

        for (int n : dataSize) {
            Integer[] arr1 = ArrayGenerator.generateRandomArray(n, n);
            Integer[] arr2 = Arrays.copyOf(arr1,arr1.length);
            Integer[] arr3 = Arrays.copyOf(arr1,arr1.length);
            Integer[] arr4 = Arrays.copyOf(arr1,arr1.length);

            SortingHelper.SortTest(SortType.HeapSort, arr1);
            SortingHelper.SortTest(SortType.HeapSort2, arr4);
            SortingHelper.SortTest(SortType.MergeSort, arr2);
            SortingHelper.SortTest(SortType.QuickSort_3w, arr3);
        }
    }
}
